package com.cw.base.jeeyc.biz.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cw.base.jeeyc.biz.converter.SysExceptionTradeConverter;
import com.cw.base.jeeyc.biz.intf.SysExceptionTradeBiz;
import com.cw.base.jeeyc.dao.mapper.SysExceptionTradeMapper;
import com.cw.base.jeeyc.dao.model.SysExceptionTradeDo;
import com.cw.base.jeeyc.sys.dto.SysExceptionTradeDto;

/**
 * 异常登记接口业务实现类
 *
 * @author admin
 * @date 2020-08-02 12:07:20
 */
@Service
public class SysExceptionTradeBizImpl extends ServiceImpl<SysExceptionTradeMapper, SysExceptionTradeDo>
    implements SysExceptionTradeBiz {
    @Autowired
    private SysExceptionTradeMapper sysExceptionTradeMapper;

    /**
     * 新增异常登记
     *
     * @param request 条件
     * @return String
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean addSysExceptionTrade(SysExceptionTradeDto request) {
        if (request == null) {
            return false;
        }
        return sysExceptionTradeMapper.insert(SysExceptionTradeConverter.dto2Do(request)) > 0;
    }

    /**
     * 更新异常登记
     *
     * @param request 条件
     * @return boolean
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean modifySysExceptionTrade(SysExceptionTradeDto request) {
        if (request == null) {
            return false;
        }
        sysExceptionTradeMapper.updateById(SysExceptionTradeConverter.dto2Do(request));
        return true;
    }

    /**
     * 删除异常登记
     *
     * @param request 条件
     * @return boolean
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean deleteSysExceptionTrade(SysExceptionTradeDto request) {
        if (request == null) {
            return false;
        }
        return sysExceptionTradeMapper.deleteById(request.getId()) > 0;
    }
}
